<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page session="true"%>
<!--如session设置为false，SPRING_SECURITY_LAST_EXCEPTION会始终为null-->
<%@ page isELIgnored="false"%>
<%-- <%@include file="../commons/_authority_check.jsp"%> --%>
<!DOCTYPE html>
<html>
<head>
<title>高考在线服务后台管理</title>
<%@include file="../commons/_meta.jsp"%>
<base href="${ctx}">
<link rel="stylesheet" href="${ctx}/assets/assetadmin/css/index.css">
<link rel="stylesheet" href="${ctx}/assets/assetadmin/css/login.css">
<script src="${ctx}/assets/assetadmin/js/index.js"></script>
<script type="text/javascript">
    function refreshCaptcha() {
        document.getElementById("img_captcha").src = "${ctx}/verifyCode?t="
                + Math.random();
    }
</script>
</head>
<body>
    <!--头部-->
    <div class="login-top">
        <div class="login-wrapper">
            <div class="login-top-left">
                <%-- <div class="img">
                    <img src="${ctx}/assets/assetadmin/images/logo.png" alt="">
                </div> --%>
                <span>高考在线服务后台管理</span>
            </div>
            <%-- <div class="login-top-right">
                <ul class="top-nav2">
                    <li><a href="" hidefocus="true"><i class="icon-yy2"></i>
                        <fmt:message key="language" /></a></li>
                </ul>
            </div> --%>
        </div>
    </div>
    <!--内容-->
    <div class="login-content">
        <div class="login-box">
            <form id="loginform" method="post" action="${ctx}admin/login">
                <!-- <form action="" type="post"> -->
                <table>
                    <tr>
                        <td class="user" colspan="2"><input id="username" type="text" name="username" lay-verify="username" autocomplete="off"
                            placeholder="<fmt:message key='Enter.login.name.here'/>" maxlength="30" value="${sessionScope['SPRING_SECURITY_LAST_USERNAME']}"></td>
                        </td>
                    </tr>
                    <tr>
                        <td class="pass" colspan="2"><input id="password" type="password" name="password" autocomplete="off" placeholder="<fmt:message key='Enter.password.here'/>" maxlength="20">
                        </td>
                    </tr>
                    <tr>
                        <td class="code-input"><input type="text" placeholder="<fmt:message key='Please.enter.the.verification.code'/>" maxlength="4" id="vcode" name="vcode" autocomplete="off" />
                        </td>
                        <td class="code-img">
                            <div>
                                <img alt="<fmt:message key='identifying.code'/>" src="${pageContext.request.contextPath}/verifyCode" title="<fmt:message key='Click.to.change'/>" id="img_captcha"
                                    onclick="javascript:refreshCaptcha();" class="kaptchaImg" style="margin-bottom: -3px; cursor: pointer" ;/>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="sub" colspan="2"><input type="submit" value="<fmt:message key='Login'/>" /></td>
                    </tr>
                    <tr>
                        <td class="tip" id="errormsg" colspan="2" style="color: red"><c:choose>
                                <c:when test="${param.error==true }">
                                    <div>
                                        <fmt:message key="Login.failed" />
                                        !
                                        <c:if test="${not empty SPRING_SECURITY_LAST_EXCEPTION }">
                                            <c:out value="${SPRING_SECURITY_LAST_EXCEPTION.message}" />
                                        </c:if>
                                    </div>
                                </c:when>
                            </c:choose></td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
    <script>
                    if (top != this) {
                        //登录页面如果不是顶层，就top定位到首页
                        top.location.href = "${pageContext.request.contextPath}/admin/";
                    }

                    function validateForm() {
                        if (empty($("#username").val())) {
                            //alertError('请输入用户名');
                            $("#errormsg").html(
                                    '<fmt:message key="enter.one.user.name"/>');
                            return false;
                        }
                        if (empty($("#password").val())) {
                            //alertError('请输入密码');
                            $("#errormsg")
                                    .html(
                                            '<fmt:message key="Please.input.a.password"/>');
                            return false;
                        }
                        if (empty($("#vcode").val())) {
                            //alertError('请输入密码');
                            $("#errormsg")
                                    .html(
                                            '<fmt:message key="Please.enter.the.verification.code"/>');
                            return false;
                        }

                        $("#loginform").submit();
                    }

                    document.onkeydown = keyDownSearch;

                    function keyDownSearch(e) {
                        // 兼容FF和IE和Opera    
                        var theEvent = e || window.event;
                        var code = theEvent.keyCode || theEvent.which
                                || theEvent.charCode;
                        if (code == 13) {
                            validateForm();
                            return false;
                        }
                        return true;
                    }

                    jQuery(document).ready(function() {
                        $("#username").focus();
                    });
                </script>
</body>
</html>
